package org.gary.base.service.impl;

import javax.annotation.Resource;

import org.gary.base.dao.ImageDao;
import org.gary.base.model.Image;
import org.gary.base.service.ImageService;
import org.gary.core.factories.impl.BasicServiceFactoryImpl;
import org.gary.core.util.ResultMessage;
import org.springframework.stereotype.Component;

/**
 * image Service 类
 * 
 * @author lengreen
 * 
 */
@Component("imageService")
public class ImageServiceImpl extends BasicServiceFactoryImpl<Image> implements
		ImageService {
	private ImageDao imageDao;
	
	/**
	 * 重写basicServicefactoryimpl中的Save方法， 重写以加入日志模块，并记录日志
	 */
	@Override
	public String save(Image image) {
		// 在图片保存之前记录一条日志
		getLoggerService().makeLog(image.getClass().getName(),
				"开始保存一张图片" + image);
		getBasicDaoFactory().save(image);
		// 在图片保存之后记录一条日志
		getLoggerService().makeLog(image.getClass().getName(),
				"保存一张图片成功" + image);
		return ResultMessage.image.ADD_SUCCESS;
	}

	@Override
	public Image loadByName(String name) {
		return imageDao.loadByName(name);
	}

	@Resource
	public void setImageDao(ImageDao imageDao) {
		this.imageDao = imageDao;
	}

	public ImageDao getImageDao() {
		return imageDao;
	}
}
